//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#ifndef __ELASTOS_INTERRUPT_H__
#define __ELASTOS_INTERRUPT_H__

enum {
    SystemCallVector = KCONFIG_SYSTEMCALL_VECTOR,
};

typedef uint32_t    errorcode_t;

#define __DECL_HARDWARE_SAVED_REGS      \
    uint32_t    eip;                    \
    uint32_t    cs;                     \
    uint32_t    eflags;                 \
    uint32_t    _esp;                   \
    uint32_t    _ss;

#define __DECL_SOFTWARE_SAVED_REGS      \
    uint32_t    ebx;                    \
    uint32_t    ecx;                    \
    uint32_t    edx;                    \
    uint32_t    esi;                    \
    uint32_t    edi;                    \
    uint32_t    ebp;                    \
    uint32_t    eax;                    \
    uint32_t    ds;                     \
    uint32_t    es;

typedef struct InterruptContext {
    __DECL_SOFTWARE_SAVED_REGS
    union {
        irq_t       irq;
        errorcode_t errorcode;
        uint32_t    uSystemCallNo;
    } u;
    __DECL_HARDWARE_SAVED_REGS
} InterruptContext;

typedef void (CDECL *isr_t)(irq_t, void *, InterruptContext *);

EXTERN void CDECL DzRegisterIsr(irq_t irq, ipl_t ipl, isr_t isr, void *pvDevice);
EXTERN void CDECL DzUnregisterIsr(irq_t irq);

EXTERN void CDECL DzEnableIrq(irq_t irq);
EXTERN void CDECL DzDisableIrq(irq_t irq);

EXTERN ipl_t CDECL DzRaiseCurrentIpl(ipl_t ipl);
EXTERN ipl_t CDECL DzLowerCurrentIpl(ipl_t ipl);

#endif // __ELASTOS_INTERRUPT_H__
